// 引用网络请求中间件
import request from '../../utils/request.js';

const API_NAME = '/group'

/* 用户对应圈子 */

export default {
	/* 同意圈子申请 */
	agreeGroupApply(userToGroupId) {
		return request({
			url: `${API_NAME}/userToGroupApi/accept/apply?userToGroupId=${userToGroupId}`,
			method: 'PUT',
		})
	},

	/* 通过圈子码加圈子 */
	addGroupByUcode(ucode) {
		return request({
			url: `${API_NAME}/userToGroupApi/apply/code?ucode=${ucode}`,
			method: 'POST',
		})
	},
	/* 申请加入圈子 */
	applyAddGroup(groupId) {
		return request({
			url: `${API_NAME}/userToGroupApi/apply/id?groupId=${groupId}`,
			method: 'POST',
		})
	},
	/* 查询圈子申请列表 */
	findGroupApplyList() {
		return request({
			url: `${API_NAME}/userToGroupApi/apply/list`,
			method: 'GET',
		})
	},
	/* 邀请用户加入圈子 */
	inviteUserAddGroup(groupId, userId) {
		return request({
			url: `${API_NAME}/userToGroupApi/invite?groupId=${groupId}&userId=${userId}`,
			method: 'POST',
		})
	},
	/* 批量邀请用户加入圈子 */
	moreInviteUserAddGroup(groupId, userIds) {
		return request({
			url: `${API_NAME}/userToGroupApi/batchInvite?groupId=${groupId}`,
			method: 'POST',
			userIds
		})
	},
	/* 查询用户圈子列表 */
	findUserGroupList() {
		return request({
			url: `${API_NAME}/userToGroupApi/group/list`,
			method: 'GET',
		})
	},
	/* 查询用户圈子列表 by id */
	findUserGroupListById(userId) {
		return request({
			url: `${API_NAME}/userToGroupApi/group/listByUserId?userId=${userId}`,
			method: 'GET',
		})
	},
	/* 退出圈子 */
	exitGroup(ugroupId) {
		return request({
			url: `${API_NAME}/userToGroupApi/quit?ugroupId=${ugroupId}`,
			method: 'DELETE',
		})
	},
	/* 查询圈子用户列表 */
	findGroupUserList(groupId) {
		return request({
			url: `${API_NAME}/userToGroupApi/user/list?groupId=${groupId}`,
			method: 'GET',
		})
	}
}
